<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.util.Vector,com.ejoysoft.wlanyz.business.Task,com.ejoysoft.wlanyz.business.Ac,com.ejoysoft.wlanyz.business.Testtemplate,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException" %>
<%@page import="org.jaxen.function.SubstringFunction"%>
<%@page import="java.io.File"%>
<%@ include file="../include/jsp/head.jsp"%>
<%
try{
if(!globa.userSession.hasRight("10020"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
      String s=request.getParameter("fileupload");
      String l=request.getParameter("textfield");
		if(s!=null){
		//String url=s.replace("\\","/");
		String url=s.replaceAll("\\\\","\\\\\\\\");
		  //System.out.println("gggggggggggggggggggg"+url);
		Task t = new Task();
		t.method(url);
		}
		
%>

<% 
    //初始化
    Task  user0=null;
    Task obj=new Task(globa);
     Ac obj7=new Ac(globa);
    Testtemplate obj2=new Testtemplate(globa);//用于查找任务类型
    Vector<Testtemplate> vctObj2=obj2.listTask();
    //查询条件
    String strTaskMan= ParamUtil.getString(request,"strTaskMan","");
    String strTaskPhone=ParamUtil.getString(request,"strTaskPhone","");
     String strTaskName= ParamUtil.getString(request,"strTaskName","");
    String strTaskType=ParamUtil.getString(request,"strTaskType","");
    String checked1 =  ParamUtil.getString(request,"checkedFlag","all");
	String tWhere=" WHERE 1=1";
	if(!strTaskMan.equals("")){
     tWhere += " and strTaskMan LIKE '%"+ strTaskMan +"%'";
    }
	if (!strTaskName.equals("")) {
		tWhere += " and strTaskName LIKE '%" + strTaskName + "%'";
	}
	if(!strTaskPhone.equals("")){
     tWhere += " and strTaskPhone = '"+ strTaskPhone +"'";
    }
	if (!strTaskType.equals("")) {
		tWhere += " and strTaskType = '" + strTaskType + "'";
	}
	
	
	 tWhere += " "; 
	//记录总数
	int intAllCount=obj.getCount(tWhere);
	//当前页
	int intCurPage=globa.getIntCurPage();
	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集
	Vector<Task> vctObj=obj.list(tWhere,intStartNum,intPageSize);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=application.getAttribute("APP_TITLE")%></title> 
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="../include/date/popc.js"></script>
<script src="../include/js/list.js"></script>
<script src="../include/DatePicker/WdatePicker.js"></script>
<script language="javascript">
//增加信息
function add() {
   frm.action="task_add.jsp";
   frm.submit();
}


 function showAc(){
   document.getElementById('<%=Constants.PAGE_SIZE_INDEX%>').value= "1";
  frm.submit();
 }
 function export_sbm(page){ 
  frm.action="task_export.jsp";
  document.getElementById("strCurPage").value = "<%=intCurPage%>";
  document.getElementById("exportContent").value = page;
  frm.submit();
 }
 function import_sbm()
 {
 window.open ('excel.jsp','newwindow','height=100,width=425,top=320,left=450,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=no');
 }
 function del(){
	if (iCheckedNumber(document.all.strTaskId) == 0) {
		alert("请先选择要删除的记录！");
		return;
	}
    if(!confirm('您是否确认要删除所选中的所有记录？'))
        return;
     frm.action="task_act.jsp?<%=Constants.ACTION_TYPE%>=<%=Constants.DELETE_STR%>";
     frm.submit();
}

function check() {
if (iCheckedNumber(document.all.strTaskId) == 0) {
		alert("请先选择任务进行Ap下发！");
		return;
	}
if (iCheckedNumber(document.all.strTaskId) > 1) {
		alert("只能选择一个任务进行Ap下发！");
		return;
	}
 var checkboxs = window.document.getElementsByName("strTaskId");  
           for(var i=0;i<checkboxs.length;i++){
                if(checkboxs[i].checked == true){ 
                		var temp = checkboxs[i].value;
                		temps = temp.split(",");
                		//opener.document.getElementById("strTaskId").value=temps[0];
                		//opener.document.getElementById("intIssued").value=temps[1];
                		if(temps[1]==1)
                		{alert("此任务已下发Ap！");
		                 return;
                		}
                		else
                		{
                	   alert("此任务未下发Ap！");
                		
                		window.close();
                		}
                	}	
          }          
		
   // for (var i = 0; i < frm.strTaskId.length; i++)
    //    if (frm.strTaskId[i].checked)
    //        window.open("right_set.jsp?sel=" + frm.strTaskId[i].value, "权限分配", "width=370,height=650,top=20,left=50,scrollbars=yes,status=yes");
} 
function lookAP(){
if (iCheckedNumber(document.all.strTaskId) == 0) {
		alert("请先选择任务进行Ap查看！");
		return;
	}
if (iCheckedNumber(document.all.strTaskId) > 1) {
		alert("只能选择一个任务进行Ap查看！");
		return;
	}
 var checkboxs = window.document.getElementsByName("strTaskId");  
           for(var i=0;i<checkboxs.length;i++){
                if(checkboxs[i].checked == true){ 
                		var temp = checkboxs[i].value;
                		temps = temp.split(",");
                		//opener.document.getElementById("strTaskId").value=temps[0];
                		//opener.document.getElementById("intIssued").value=temps[1];
                		if(temps[1]==1)
                		{frm.action="task_lookAp.jsp?strTaskId=temps[0]";
		                 return;
                		}
                		else
                		{
                	   alert("此任务未下发Ap！");
                		
                		window.close();
                		}
                	}	
          }          



}

</script>
<style>
A {text-decoration: NONE} 
</style>
</head>


<body>
<form name=frm method=post action="task_list.jsp"> 
<input id="exportFlag" name="exportFlag" type="hidden" value="exportResult"/>
<input id="strCurPage" name="strCurPage" type="hidden" value="<%=intCurPage%>"/>
<input id="exportContent" name="exportContent" type="hidden" value=""/>
<input id="checkedFlag" name="checkedFlag" type="hidden" value="<%=checked1%>"/>
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><img src="../images/ri_list.jpg" width="14" height="14" align="bottom" />&nbsp;您现在所在的位置：<font color="#0e7cc9">任务管理</font> &gt; 任务信息管理</td>
  </tr>
</table>
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
  
  <tr>
    <td height="45" valign="middle" bgcolor="e1eef7">
      <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="20%">测试人：
          <input type="text" name="strTaskMan" value="<%=strTaskMan %>"/>
          </td>
          <td width="20%">手机号：
          <input type="text" name="strTaskPhone" value="<%=strTaskPhone%>"/>
          </td>
          <td width="21%">任务名称：
          <input type="text" name="strTaskName" value="<%=strTaskName%>"/>
          </td>
          <td width="21%">任务类型：
          <select id="strTaskType" name="strTaskType" class="input_box" >
          <option value=''>- - - - -请选择- - - - -</option>
                    <%
                    for (int i = 0;i < vctObj2.size(); i++) {
                    Testtemplate obj3 = vctObj2.get(i);
              %>
                <option value="<%=obj3.getStrTemplateName()%>"><%=obj3.getStrTemplateName()%></option>
              <%
                  }
              %>
                 </select>
          </td>
          <td>
          <img src="../images/search.jpg" width="58" height="28"  onclick="showAc()" style="cursor:hand"/></td>
          <td width="11%" align="right"><img src="../images/add.jpg" width="64" height="27" onclick="add()" style="cursor:hand"/></td>
        </tr>
      </table></td>
  </tr>
</table>

<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr>
    <td width="6%" class="listtit"  style="border-left:1px solid #32a4ea;"><input type="checkbox" name="checkbox62" value="checkbox" onclick="selAll(document.all.strId)" style="height:12px;" />
    全选</td>
    <td width="5%" class="listtit">测试人</td>
    <td width="8%" class="listtit">测试手机号</td>
    <td width="12%" class="listtit">热点名称</td>
    <td width="7%" class="listtit">任务名称</td>
    <td width="7%" class="listtit">任务类型</td>
    <td width="6%" class="listtit">网络类型</td>
    <td width="23%" class="listtit">任务时限</td>
    <td width="6%" class="listtit">测试次数</td>
    <td width="6%" class="listtit">是否下发</td>
    <td width="14%" class="listtit">基本操作</td>
  </tr>
    <%
            
              for (int i = 0;i < vctObj.size(); i++) {
              String Id="";
              String Man="";
              String Phone= "";
              String HotpotName = "";
              String Name ="";
              String Type ="";
              String NetType ="";
              String time ="";
              int Count=0;
              Task obj1 = vctObj.get(i);
             
                int intIssued = obj1.getIntIssued();
                String intIssuedstring = intIssued == 0?"未下发":"已下发";
                if(obj1.getStrTaskId()!=null)Id=obj1.getStrTaskId();
                if(obj1.getStrTaskMan()!=null)Man=obj1.getStrTaskMan();
            	if(obj1.getStrTaskPhone()!=null)Phone=obj1.getStrTaskPhone();
            	if(obj1.getStrHotpotName()!=null)HotpotName=obj1.getStrHotpotName();
            	if(obj1.getStrTaskName()!=null)Name=obj1.getStrTaskName();
            	if(obj1.getStrTaskType()!=null)Type=obj1.getStrTaskType();
            	if(obj1.getStrNetType()!=null)NetType=obj1.getStrNetType();
            	if(obj1.getDtStartTime()!=null||obj1.getDtEndTime()!=null)time=obj1.getDtStartTime()+"———"+obj1.getDtEndTime();
            	Count=obj1.getStrTestCount();
            %>

  <tr>
    <td class="listd1" style="border-left:1px solid #dddddd;">
    <input type="checkbox"  id=strTaskId name=strTaskId value="<%=Id%>" style="height:12px;" /></td>
    <td class="listd1" style="border-left:1px solid #dddddd;"><%=Man%>&nbsp;</td>
    <td class="listd1"><%=Phone%>&nbsp;</td>
    <td class="listd1"><%=obj7.listhotpotname(HotpotName) %>&nbsp;</td>
    <td class="listd1"><%=Name %>&nbsp;</td>
    <td class="listd1"><%=Type %>&nbsp;</td>
    <td class="listd1"><%=NetType %>&nbsp;</td>
    <td class="listd1"><%=time %>&nbsp;</td>
    <td class="listd1"><%=Count%>&nbsp;</td>
    <td class="listd1"><%=intIssuedstring%>&nbsp;</td>

    <td class="listdrd" style="border-right:1px solid #dddddd;"> <a href="task_update.jsp?strTaskId=<%=obj1.getStrTaskId()%>" >修改</a>&nbsp;<a href="#" onclick="if(confirm('确认删除该记录？')){location.href='task_act.jsp?<%=Constants.ACTION_TYPE%>=<%=Constants.DELETE_STR%>&strTaskId=<%=obj1.getStrTaskId()%>';}" >删除</a>&nbsp;<a href="task_lookAp.jsp?strTaskId=<%=obj1.getStrTaskId()%>" >查看Ap</a>&nbsp;<a href="task_chooseap.jsp?strTaskId=<%=obj1.getStrTaskId()%>" >下发Ap</a></td>  </tr>
             <%
            }
            %>
</table>

<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10%" height="50" valign="bottom"><img src="../images/pldel.jpg" width="83" height="27" align="middle" onclick="del();"/></td>
    <td width="61%" height="50" valign="bottom"><!--<img src="../images/pldel.jpg" width="83" height="27" align="middle" />--> &nbsp;&nbsp;页面记录数
      <select name="strPageSize" id="strPageSize" style="width:52px;" onchange="showAc()">
		<% 
		 String sltOpt[] = {"10","20","30","50","70","100","所有"};
		 for(int i=0; i < sltOpt.length;i++){
		 	String selected = "";
		    if(sltOpt[i].equals(strPageSize))
		      selected="selected='selected'";
		 %>
		 <option value="<%=sltOpt[i] %>" <%=selected %>><%=sltOpt[i] %></option>
   		<%
   		 }
   		 %>
   		 </select>
      <img src="../images/dc.jpg" width="92" height="27" align="middle" onclick="export_sbm('currentPage')" style="cursor:hand"/> 
      <img src="../images/dcall.jpg" width="82" height="27" align="middle" onclick="export_sbm('allPage')" style="cursor:hand"/>
      <input name="B1" type="button" value="导入" onclick="import_sbm()"   />
      </td>
      
      <td>  <input id="exportFlag" name="exportFlag" type="hidden" value="exportResult"/>
       		 <input id="strCurPage" name="strCurPage" type="hidden" value=""/>
			<input id="exportContent" name="exportContent" type="hidden" value=""/></td>
    
      <td width="39%" align="right" valign="bottom"><!--<table width="310" border="0" cellspacing="0" cellpadding="0">
       <tr>
        <td width="40"><img src="../images/up.jpg" width="40" height="30" /></td>
        <td width="221" align="center" background="../images/page_bg.jpg" class="page"><a href="#">1</a>&nbsp; <a href="#">2</a>&nbsp; <a href="#">3</a>&nbsp; <a href="#"><span class="sel">4</span></a>&nbsp; <a href="#">5</a> &nbsp;<a href="#">6</a> &nbsp;<a href="#">7</a>&nbsp; <a href="#">8 </a>&nbsp;<a href="#">9</a>&nbsp;...&nbsp;<a href="#">13</a> </td>
        <td width="39"><img src="../images/down.jpg" width="39" height="30" /></td>
       </tr>
    </table>
  -->
  <!-- 翻页开始 -->  
     	<%@ include file="../include/jsp/cpage.jsp"%>
       	<!-- 翻页结束 --> </td>
  </tr>
</table>




 </form>
</body>
</html>
<%
}catch(Exception e){e.printStackTrace();}
 %>
<%@ include file="../include/jsp/footer.jsp"%>